Private Declare Function timeGetTime Lib "winmm.dll" () As Long

Sub test()
    Dim cn As New ADODB.Connection
    
    Dim tdata As Table
    Dim sql(50) As String
    
    Set tdata = ActiveDocument.Tables(1)
    docName = ActiveDocument.Name
    
    Dim cnStr As String
    
    'database
    cnStr = "Provider = MSDAORA.1;Password=" & "lisro" & _
                     ";User ID=" & "lisro" & ";Data Source=" & "fanying" & ";Persist Security Info=True"
    
    cn.Open cnStr
    
    n = 1
    
    For i = 1 To 50
        If Mid(Trim(tdata.Cell(i, 3).Range.Text), 1, 6) = "select" Then
            
           ' MsgBox n
            
            
            sql(n) = (Mid(ActiveDocument.Tables(1).Cell(i, 3).Range.Text, 1, _
                Len(ActiveDocument.Tables(1).Cell(i, 3).Range.Text) - 2))

            
            a = timeGetTime
            
            cn.Execute sql(n)
            
            b = timeGetTime
            
            execTime = b - a
            
           
            sqlT = Replace(sql(n), "'", "''")
            
            
        cn.Execute "insert into sqlchange values ('" & Mid(docName, 1, 7) & "', '" & n & "' , '" & sqlT & "',  '" & execTime & "')"
            
            n = n + 1
            
        End If
    Next i
End Sub


